<template>
  <div class="header">
    <div class="wrap">
      <div class="b" @click="_back">
        <i class="iconfont icon-tuihui b-i"></i>
      </div>
      <transition :enter-class="slideOut" :leave-active-class="slideIn2">
        <h1 class="t" v-show="title">
          <span>{{title}}</span>
        </h1>
      </transition>
    </div>
  </div>
</template>

<script>
  import {mapGetters, mapState} from 'vuex'

  export default {
    name: 'header',
    methods: {
      _back(){
        window.goBack();
      }
    },
    computed: {
      ...mapState([
        'slideIn',
        'slideIn2',
        'slideOut',
      ]),
      ...mapGetters([
        'title',
      ])
    }
  }
</script>

<style scoped lang="scss">
  @import "../css/mixin";

  .header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background-color: #fff;
    border-bottom: 1px solid #d8d8d8;

    .wrap {
      position: relative;
    }

    $height: 40px;
    @mixin _height {
      height: $height;
      line-height: $height;
      text-align: center;
    }

    .b {
      position: absolute;
      left: 0;
      top: 0;
      width: 46px;
      font-size: 22px;
      @include _height;
      &:active .b-i {
        font-size: 26px;
      }
      .b-i {
        font-size: 22px;
        font-weight: 700;
      }
    }

    .t {
      margin: 0 88px;
      position: relative;
      width: auto;
      font-weight: 400;
      font-size: 16px;
      @include wordHidden;
      @include _height;
      transition: all .3s ease;
    }
  }
</style>
